package com.neusoft.question.staticdemo;

public class Person {
	
	//总人数
	private static int sum;

	//静态属性
	private  String name;
	//非静态属性
	private final String gender;
	
	//静态代码块
	static {
		System.out.println("这是person的静态代码块");
	}
	
	//非静态代码块
	{
		System.out.println("这是person的非静态代码块");
	}
	

//	public Person() {
//		super();
//		System.out.println("person的默认构造方法");
//	}

	public Person(String name,String gender) {
		super();
		this.name = name;
		this.gender = gender;
		sum++;
	}
	
	public static void eat() {
		System.out.println("person的静态eat方法");
	}
	
	public  void sleep() {
		
		System.out.println("person的非静态sleep方法");
	}

	public  String getName() {
		return name;
	}

	public  void setName(String name) {
		this.name = name;
	}

	public String getGender() {
		return gender;
	}
//final 不能再set
//	public void setGender(String gender) {
//		this.gender = gender;
//	}

	@Override
	public String toString() {
		return "Person [gender=" + gender + ", getGender()=" + getGender() + ", getClass()=" + getClass()
				+ ", hashCode()=" + hashCode() + ", toString()=" + super.toString() + "]";
	}

	public static int getSum() {
		return sum;
	}

	

	
	
	
	
}
